home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
273_01
/
tcutil.doc
< prev
next >
Wrap
Text File
|
1988-05-02
|
42KB
|
1,478 lines
TCUTIL
TurboC Utilities
Developed By Jim Derr
2425 Santa Cruz Ct.
Santa Rosa, Ca. 95401
This is may first attempt at distributing software. I have found
numerous execelant software tools and packages on BBS's and I hope
that someone can find these routines usefull.
After I received TURBOC in the mail I was dismayed to find out that
it did not contain any video or bios routines. So in order to use
TURBOC I set out looking for a commerical package and/or a shareware
package to meet my needs. The commerical packages were a little steep
in price and the most of the shareware packaged were overkill.
I decided to develop a set of my own routines and distribute them to
the BBS community. This is my first cut at the routines with more
and better things to come. I have included the source code for all
the routines. All the routines have been tested using the tiny and
small memory models.
Just to protect myself I do not guarantee these routines, use them
at your own risk. They have been tested on PC/XT's, 3270-PC's,
Personal System/2 model 60, and Compaq Portables. They should
work on any good clone that is BIOS compatable.
I have also included the small library files for those of
you that do not have access to a lib program. Also included are
bat files to compile and reproduce the lib file.
PLEASE NOTE THAT THERE ARE MANY HOURS OF WORK IN THESE ROUTINES.
IF YOU FIND THEM USEFULL AND YOU USE THEM IN YOUR PROGRAMS PLEASE SEND
$10 TO THE ADDRESS SHOWN ON PAGE 1 OF THIS DOCUMENT.
Files Included are:
tcutil.doc the documentation file
tcutil.h the header file required by the routines
tcutils.lib the small model library file
compall.bat a batch file to compile all the source code.
*.cc source of functions that are written entirely in c.
*.ca source of functions that use inline assembler code.
Notes on Using these routines:
Most of these routines are fairly self explanitory. However a few
need some additional comments.
BEFORE USING ANY OF THESE ROUTINES IN YOUR PROGRAM YOU MUST!!!!!!!!!!!
USE THE VIDEO_TYPE ROUTINES.
This routine sets up some global
variables that the other routines will use. If you complie your
program and get an undefined refenece to any one of the following
you forgot to use the video_type routine.
bios, cga, ega, color, mono, scrseg.
The make_window routine does not save the portion of the screen it
is writing over. There are times when I don't want to save the area
and I don't want a routine assuming I want to save it. If you want
to save the information under the window use the save_scr and rest_scr
functions to save and restore the information.
The save_scr function does not allocate memory for you, you must do
it yourself. This allows you the freedom to either allocate it
statically or dynamically. Included in the tcutil header file are
two macros that will correctly calculate the amount of memory you
need to allocate to save the information under a given window.
The following two examples show how to use these macros:
STATIC ALLOCATION:------------------------------------------------------
#define screen1_size setsize_w(0,0,24,79) /*number of bytes needed to
char save_screen1[screen1_size]; save a full screen with
. no shadow */
.
.
save_scr(0,0,24,79,save_screen1);
DYNAMIC ALLOCATION:-----------------------------------------------------
#define screen2_size setsize_ws(0,0,10,20) /*number of bytes needed to
char *save_point; save a screen with the
save_point = (char *)malloc(screen2_size); coordinated of 0,0,10,20
. that will have a shadow */
.
.
save_scr(0,0,10,20,save_point);
There is also another macro in the TCUTIL.H file to aid you in
defining attribute bytes. To use it code your attributes as
follows:
int attr1 = setatr(BLUE,BLACK,0,0);
| | | |
forground color-----+ | | |
background color----------+ | |
blink-------------------------+ | (where blink and bold is 0 or 1)
bold----------------------------+
Most of the routines do not return any values. However if they do
the value returned and it's type is shown in the documentation of
the function.
RELEASE 2.0 10/19/87 UPDATES:
The following new functions have been added to release 2.0:
beep activate the speaker.
get_xa read a keystoke and return normal and extended key codes.
soundx compute a soundex code for a string
str_xform transform characters in a string
The following functions have been enhanced or changed.
writef enhanced for speed.
get_line enhanced/changed. The function will now return any non-printable
character as an extended coded int.
TCUTIL.H extended coded ints are now defined in the header.
RELEASE 3.0 2/15/88 UPDATES:
The following new functions have been addded:
getfield read a string from the screen under control of a format mask.
xprintf like printf but writes directly to the video buffer.
melt 4 different ways to restore the screen.
If you find any error or bugs please drop me a line.
Also if there is some function
you would like added to this library also drop me a line.
!!!!ENJOY!!!!!
Jim Derr
2425 Santa Cruz Ct.
Santa Rosa, Ca. 95401
beep [BEEP.CC]
void beep(unsigned int pitch, unsigned int nticks )
/* Sound the speaker using indicated pitch for nticks long
for error sound use beep(440,3) beep(220,3)
*/
--------------------------------------------------------------------------
box [BOX.CC]
void box(int trow, int tcol, int lrow, int lcol, int wattr, int battr)
/* This will draw a box using upper left row,col and lower right row,col
wattr is attribute character for center of box, battr is the border attr.
*/
--------------------------------------------------------------------------
calc_tots [CALCTOT.CC]
long calc_tots(char *curr_path)
/* This function will accept a valid path name I.E. c:\dos and will return
the total number of bytes occupied by all files in the specified directory.
*/
--------------------------------------------------------------------------
ccolor [CCOLOR.CC]
ccolor(int row, int col, int attr, int len)
/* This routine will change the color attributes of a column of characters.
row=row to start changing color
col=col to start changing color
attr=attribute to change to
len=number of rows down the screen to change.
*/
--------------------------------------------------------------------------
- 1 -
change_to [CHGTO.CC]
change_to(char *dir)
/*
┌────────────────────────────────────────────────────────────────────┐
│Purpose: To change the current disk drive and directory with │
│ one call. │
│ Inputs: Char *dir points to directory to change to. This may │
│ contain a drive letter if required. │
│Outputs: None. │
│ │
│ Return: 0 = successful. │
│ -1 = directory not found. │
└────────────────────────────────────────────────────────────────────┘
*/
--------------------------------